home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / scsh-0.4 / scsh-0 / scsh-0.4.2 / scsh / bsd / fdflags.scm < prev    next >
Text File  |  1995-11-04  |  2KB  |  87 lines

  1. ;;; Flags for open(2) and fcntl(2).
  2. ;;; Copyright (c) 1993 by Olin Shivers.
  3. ;;; Copyright (c) 1994 by Brian D. Carlstrom
  4.  
  5. (define-syntax define-open-flags
  6.   (syntax-rules ()
  7.     ((define-opens form ...)
  8.      (begin (define-enum-constant "open" . form) ...))))
  9.  
  10. (define-open-flags
  11.   ;; POSIX
  12.   (read            #x0000)
  13.   (write        #x0001)
  14.   (read+write        #x0002)
  15.   (nonblocking        #x0004)        ; no delay
  16.   (append        #x0008)        ; set append mode
  17.   
  18.   ;; BSD4.4-Lite
  19.   (shlock        #x0010)        ; open with shared file lock
  20.   (exlock        #x0020)        ; open with exclusive file lock
  21.   (async        #x0040)        ; signal pgrep when data ready
  22.   (fsync             #x0080)        ; synchronus writes
  23.  
  24.   ;; POSIX
  25.   (create               #x0200)        ; create if nonexistant
  26.   (truncate             #x0400)        ; truncate to zero length
  27.   (exclusive            #x0800)        ; error if already exists
  28.   (no-control-tty    #x0000))    ; don't assign controlling terminal
  29.  
  30.  
  31.  
  32. (define open/access-mask
  33.   (bitwise-ior open/read
  34.            (bitwise-ior open/write open/read+write)))
  35.  
  36. ;;;; fcntl
  37. ;;;; Rough sketch only. Will define a separate proc for each fcntl command.
  38. ;
  39. ;;;; fcntl commands
  40. ;dup
  41. ;
  42. ;get-flags    ; Only gives close-on-exec bit.
  43. ;set-flags
  44. ;
  45. ;get-status    ; Returns open flags + get-status flags (below)
  46. ;set-status    ; Can set: append, sync, async, nbio, nonblocking, no-delay
  47. ;
  48. ;get-lock
  49. ;set-lock
  50. ;nonblocking-set-lock
  51. ;
  52. ;get-record-lock
  53. ;set-record-lock
  54. ;
  55. ;get-owner            ; Not POSIX
  56. ;set-owner            ; Not POSIX
  57. ;remote-set-lock        ; Not POSIX
  58. ;nonblocking-remote-set-lock    ; Not POSIX
  59. ;remote-get-lock        ; Not POSIX
  60. ;
  61. ;;;; Flags
  62. ;
  63. ;close-on-exec    ; get-flags
  64. ;
  65. ;async        ; get-status
  66. ;no-delay    ; get-status
  67. ;nbio        ; get-status
  68. ;
  69. ;;; These are internal; they are not part of the supported scsh interface.
  70.  
  71. (define fcntl/close-on-exec         1)
  72.  
  73. (define fcntl/dupfd            0)
  74. (define fcntl/get-fd-flags        1)
  75. (define fcntl/set-fd-flags        2)
  76. (define fcntl/get-file-flags        3)
  77. (define fcntl/set-file-flags        4)
  78. (define fcntl/get-owner            5)    ; Not POSIX
  79. (define fcntl/set-owner            6)    ; Not POSIX
  80. (define fcntl/get-record-lock        7)    ; F_GETLK
  81. (define fcntl/set-record-lock-noblock    8)    ; F_SETLK
  82. (define fcntl/set-record-lock        9)    ; F_SETLKW
  83.  
  84. (define lock/read    1)    ; F_RDLCK
  85. (define lock/release    2)    ; F_UNLCK
  86. (define lock/write    3)    ; F_WRLCK
  87.